package com.spddr.pmos.jpa;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;

import org.joda.time.LocalDate;
import org.joda.time.Period;

import cn.seqdata.jpa.AbstractPersistable;

import com.fasterxml.jackson.databind.annotation.JsonSerialize;

@Entity
@Table(name = "contract_detail")
public class ContractDetail extends AbstractPersistable<ContractDetailId> {
	private static final long serialVersionUID = 1L;

	private Double energy;
	private Double price;
	private Double fee;
	private CryotoKey cryotoKey;
	private byte[] cryptoEnergy;
	private byte[] cryptoPrice;
	private byte[] cryptoFee;

	public ContractDetail() {
	}

	public ContractDetail(long contract, LocalDate date, Period period, int psv) {
		setId(new ContractDetailId(contract, date, period, psv));
	}

	@Column(name = "energy", precision = 18, scale = 3)
	public Double getEnergy() {
		return this.energy;
	}

	public void setEnergy(Double energy) {
		this.energy = energy;
	}

	@Column(name = "price", scale = 4)
	public Double getPrice() {
		return this.price;
	}

	public void setPrice(Double price) {
		this.price = price;
	}

	@Column(name = "fee", scale = 4)
	public Double getFee() {
		return this.fee;
	}

	public void setFee(Double fee) {
		this.fee = fee;
	}

	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "crypto_keyid")
	@JsonSerialize(using = cn.seqdata.jackson.TypeSerializer.IdName.class)
	public CryotoKey getCryotoKey() {
		return this.cryotoKey;
	}

	public void setCryotoKey(CryotoKey cryotoKey) {
		this.cryotoKey = cryotoKey;
	}

	@Column(name = "crypto_energy")
	public byte[] getCryptoEnergy() {
		return this.cryptoEnergy;
	}

	public void setCryptoEnergy(byte[] cryptoEnergy) {
		this.cryptoEnergy = cryptoEnergy;
	}

	@Column(name = "crypto_price")
	public byte[] getCryptoPrice() {
		return this.cryptoPrice;
	}

	public void setCryptoPrice(byte[] cryptoPrice) {
		this.cryptoPrice = cryptoPrice;
	}

	@Column(name = "crypto_fee")
	public byte[] getCryptoFee() {
		return this.cryptoFee;
	}

	public void setCryptoFee(byte[] cryptoFee) {
		this.cryptoFee = cryptoFee;
	}
}